package leetcode.leetcode_73;

import java.util.ArrayList;

class Solution {
    public void setZeroes(int[][] matrix) {
        int n = matrix.length;
        int m = matrix[0].length;
        int[][] ans = new int[n][m];
        ArrayList<Integer> col = new ArrayList<>();
        ArrayList<Integer> row = new ArrayList<>();
        for (int i = 0; i < n; i++){
            for (int j = 0; j < m; j++){
                if (matrix[i][j] == 0){
                    col.add(j);
                    row.add(i);
                }
            }
        }
        for (int i : col){
            for (int j = 0; j < n; j++){
                matrix[j][i] = 0;
            }
        }
        for (int i : row){
            for (int j = 0; j < m; j++){
                matrix[i][j] = 0;
            }
        }
    }
}